<include file="Public:header" />
{:W('Navigation')}
<script src="__PUBLIC__/js/datepicker/WdatePicker.js"></script>
<div class="body-right">
	<div class="row-table">
		<div class="row-table-title">公告管理</div>
		<div class="row-table-body">
			<p class="form-title">
				公告管理<a class="pull-right btn btn-primary btn-xs" href="{:U('core/announcement/add')}">发布公告</a>
				<form id="search_form" action="" method="get">
					<input type="hidden" name="g" value="core"/>
					<input type="hidden" name="m" value="announcement"/>
					<div class="form-inline" >
						<div class="form-group">
							标题&nbsp;
							<input type="text" class="form-control" id="search_title" name="search_title" />
						</div>&nbsp;&nbsp;
						<div class="form-group">
							内容&nbsp;
							<input type="text" class="form-control" id="search_content" name="search_content" />
						</div>&nbsp;&nbsp;
						<div class="form-group">
							发布人&nbsp;
							<input type="hidden" class="form-control" id="dialog_user_id" name="search_user_id" />
							<input type="text" class="form-control" id="dialog_user_name" name="search_user_name" />
						</div>&nbsp;&nbsp;
						<div class="form-group">
							状态&nbsp;
							<select class="form-control" id="search_status" name="search_status">
								<option value="">全部</option>
								<option value="1">发布中</option>
								<option value="2">停用</option>
							</select>
						</div>&nbsp;&nbsp;
						<div class="form-group">
							<input type="text" class="form-control" id="search_create_time" name="search_create_time" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" placeholder="发布时间"/>
						</div>
						<input type="button" class="btn search_btn" value="搜索" />
					</div>
				</form>
			</p>
			<if condition="empty($announcementlist)">
				<div>---暂无数据---</div>
			<else />
			<form id="form1" action="" method="post">
				<table class="table" style="margin-bottom:0px;">
					<tbody>
						<tr>
							<th><input type="checkbox" id="check_all" /></th>
							<th>标题</th>
							<th>发布人</th>
							<th>发布时间</th>
							<th>状态</th>
							<th>置顶</th>
							<th>操作</th>
						</tr>
						<volist name="announcementlist" id="vo">
						<tr>
							<td><input type="checkbox" class="check_list" name="id[]" value="{$vo.announcement_id}" /></td>
							<td><a href="{:U('core/announcement/view','id='.$vo['announcement_id'])}" style="color:#{$vo.color}">{$vo.title}</a></td>
							<td>{$vo.creator_user_name}</td>
							<td>{$vo.create_time|date='Y-m-d H:i:s',###}</td>
							<td>{$vo.status_name}</td>
							<td><if condition="'0' eq $vo['set_top']">否<elseif condition="'1' eq $vo['set_top']" />是</if></td>
							<td><a href="{:U('core/announcement/edit','id='.$vo['announcement_id'])}">编辑</a>&nbsp;|&nbsp;<a href="{:U('core/announcement/delete','id='.$vo['announcement_id'])}">删除</a></td>
						</tr>
						</volist>
					</tbody>
					<tfoot>
						<tr>
							<td><input class="btn btn-primary btn-xs" type="button" id="submit_delete" value="删除" /></td>
							<td colspan="6">{$page}<div class="clear"></div></td>
						</tr>
					</tfoot>
				</table>
			</form>
			</if>
		</div>
	</div>
</div>
<div class="clear"></div>
<script type="text/javascript">
	/**
	 * 全选
	 */
	$("#check_all").click(function(){
		$("input[class='check_list']").prop('checked',$(this).prop('checked'));
	});
	
	/**
	 * 删除
	 */
	$("#submit_delete").click(function(){
		if(confirm('确认要删除么？')){
			$('#form1').attr('action', "{:U('core/announcement/delete')}");
			$('#form1').submit();
		}
	});
	
	/**
	 * 保留搜索项
	 */
	$("#search_title").prop('value', '{$Think.get.search_title}');
	$("#search_content").prop('value', '{$Think.get.search_content}');
	$("#dialog_user_name").prop('value', '{$Think.get.search_user_name}');
	$("#search_status").prop('value', '{$Think.get.search_status}');
	$("#search_create_time").prop('value', '{$Think.get.search_create_time}');
	
	$('#dialog_user_name').click(function(){
		$('#alert').modal({
				show:true,
				remote:'{:U("core/user/getsubuserdialog", "self=1")}'
			});
	});
	
	/**
	 * 单击提交搜索表单
	 * 双击清空搜索项
	 **/
	$(function(){
		var TimeFn = null;
		$('.btn.search_btn').click(function () {
			clearTimeout(TimeFn);
			TimeFn = setTimeout(function(){
				$('#search_form').submit();
			},300);
		});
		
		$('.btn.search_btn').dblclick(function () {
			clearTimeout(TimeFn);
			window.location.href="{:U('core/announcement/index')}";
		})
	});
</script>
<include file="Public:alert" />
<include file="Public:footer" />